<?php
	$email = $_POST['email'];
	//$name = $_POST['name'];
	$address = $_POST['address'];
	$time = $_POST['arrivalTime'];
	
	// $email = "the@gmail.com";
	// $name = "ass";
	// $address = "ddfss";
	// $time = "2008-01-02 01:01:01.000002";
	
	//Notice the $time above is the format for date
	$con = mysqli_connect('localhost','root','','cs2102') or die("fail");
	if(mysqli_connect_errno($con))
	{
		echo "error";
	}
	else
	{
		$orderNum = Date("AY-m-d-h-i-s");
		//$pre_query = "SELECT * FROM restaurant WHERE address = \"$address\"";

		//$pre_result = mysqli_query($con,$pre_query);

		//while($row = mysqli_fetch_array($pre_result)){
			//$name = $row['name'];
		//}

		$query = "INSERT INTO orders values ( \"$email\", \"$orderNum\",\"$time\",\"$address\") ";;
		// $query = "INSERT INTO orders values ( \"$email\", \"$orderNum\", \" $time\", \"$name\", \"$address\") ";
		if(mysqli_query($con,$query)){
			echo "Success";
		}
		else{
			echo "Fail";
		}
	}
	
	mysqli_close($con);
?>